using System;
using System.Collections.Generic;
using System.Text;
using Registry = Microsoft.Win32.Registry;

namespace SqlBuddy
{
    class RegistrySettings
    {
        private const string sqlBuddyRegistryPath = @"HKEY_CURRENT_USER\Software\MurraySoft\SQLBuddy";
        private string[] settings =
            {
                "InputSource",
                "OutputTarget",
                "ConnectionPath",
                "InputFilePath",
                "OutputFilePath",
                "InputWindowWordWrap",
                "OutputWindowWordWrap",
                "ErrorMessagesWordWrap",
                "ConnectionFile"
            };
        private Dictionary<string, RegistrySetting> settingDictionary;
        public void Load()
        {
            settingDictionary = new Dictionary<string, RegistrySetting>();
            foreach (string s in settings)
                settingDictionary.Add(s, new RegistrySetting(sqlBuddyRegistryPath, s));
            foreach (RegistrySetting r in settingDictionary.Values)
                r.Load();
        }
        public void Save()
        {
            foreach (RegistrySetting r in settingDictionary.Values)
                if(r.Value != null)
                    r.Save();
        }
        public string Get(string key)
        {
            return (settingDictionary[key].Value);
        }
        public void Set(string key, string value)
        {
            settingDictionary[key].Value = value;
        }
    }
}
